home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Online / opennap / napster.txt < prev    next >
Text File  |  2001-06-08  |  44KB  |  1,503 lines

  1. napster messages
  2. ================
  3.  
  4. by drscholl@users.sourceforge.net
  5. December 28, 2000
  6.  
  7. 0.  Foreward
  8.  
  9. This is meant to be an open specification.  If you find errors or know of
  10. additional functionality not described hereafter, please send me email.  It
  11. benefits the entire community to have a complete and accurate protocol
  12. specification.  Not only does it allow for clients to be developed for any
  13. platform, but also decreases the strain on the server having to parse out
  14. bad client messages.
  15.  
  16. Disclaimer: The following information was gathered by analyzing the protocol
  17. between the linux nap client and may not resemble the official Windows client
  18. protocol.
  19.  
  20. 1.  Recent Changes
  21.  
  22. * numeric 607 adds download client's speed (2000-12-28)
  23. * added new numerics 640-642 for direct client to client browsing support
  24.   (2000-12-23)
  25.  
  26. 2.  Client-Server protocol
  27.  
  28. Napster uses TCP for client to server communication.  Typically the servers
  29. run on ports 8888 and 7777.  Note that this is different from the `metaserver'
  30. (or redirector) which runs on port 8875.
  31.  
  32. each message to/from the server is in the form of
  33.     <length><type><data>
  34. where <length> and <type> are 2 bytes each.  <length> specifies the length in
  35. bytes of the <data> portion of the message.  Be aware that <length> and <type>
  36. appear to be in little-endian format (least significant byte goes first).  For
  37. example, in the C language you would encode the number 1 as
  38.     const unsigned char num[2] = { 0x01, 0x00 };
  39. and 256 would be encoded as
  40.     const unsigned char num[2] = { 0x00, 0x01 };
  41. [The above is for illustrative purposes only, there are much quicker ways to
  42. actually encode a number. -ed]
  43. The <data> portion of the message is a plain ASCII string.
  44.  
  45. Note that in many cases, strings are passed as double-quoted entries.  For
  46. example, filenames and client id strings are always sent as
  47.     "random band - generic cowboy song.mp3"
  48. or
  49.     "nap v0.8"
  50. Where required, double quotes are used in the description of the messages
  51. below.
  52.  
  53. Some additional information about use of quotes inside of quotes:
  54. > The answer is, no, it doesn't do escaping of quotes.  If you try searching
  55. > for the phrase 'a "quoted" string' on the windows client, you get no songs
  56. > found, and "invalid search request" printed in yellow in your console
  57. > window.  (don't know what code that is, sorry.)
  58. >
  59. > and no wonder-- a little birdie told me that the client sends this:
  60. >
  61. > FILENAME CONTAINS "a "quoted" string" MAX_RESULTS 100
  62.  
  63. [contributed by Ben Byer <bbyer@rice.edu>.  -ed]
  64.  
  65. Note that unlike the IRC protocol, each line does NOT end in \r\n.  The
  66. <length> field specifies exactly how much data you should read.
  67.  
  68. 3.  Message Types
  69.  
  70. The following section describes the format of the <data> section for each
  71. specific message type.  Each field is denoted with <>.  The fields in a
  72. message are separated by a single space character (ASCII 32).  Where
  73. appropriate, examples of the <data> section for each message are given.
  74.  
  75. <type> can be one of the following (converted to big-endian):
  76.  
  77. 0    error message [SERVER]
  78.  
  79.     Format: <message>
  80.  
  81. 2    login [CLIENT]
  82.  
  83.     Format: <nick> <password> <port> "<client-info>" <link-type> [ <num> ]
  84.  
  85.     <port> is the port the client is listening on for data transfer.  if
  86.         this value is 0, it means that the client is behind a firewall
  87.         and can only push files outward.  it is expected that requests
  88.         for downloads be made using the 500 message (see below)
  89.     <client-info> is a string containing the client version info
  90.     <link-type> is an integer indicating the client's bandwidth
  91.         0  unknown
  92.         1  14.4 kbps
  93.         2  28.8 kpbs
  94.         3  33.6 kbps
  95.         4  56.7 kbps
  96.         5  64K ISDN
  97.         6  128K ISDN
  98.         7  Cable
  99.         8  DSL
  100.         9  T1
  101.         10 T3 or greater
  102.     <num> build number for the windows client [optional]
  103.         
  104.     Example:
  105.  
  106.     foo badpass 6699 "nap v0.8" 3
  107.  
  108. 3    login ack [SERVER]
  109.  
  110.     Format: <email>
  111.  
  112.     the server sends this message to the client after a succesful
  113.     login (2).  If the nick is registered, the <email> address given at
  114.     registration time is returned.  If the nick is not registered, a
  115.     dummy value is returned.
  116.  
  117. 4       version check [CLIENT]
  118.  
  119.         Format: <version>
  120.  
  121.     Server sends [5] if an update is needed. All other responses are
  122.     ignored.
  123.  
  124.     <version> = string, version 2.0b5a sends "2.0"
  125.  
  126. 5       "auto-upgrade" [SERVER]
  127.  
  128.         Format: <version> <hostname:filename>
  129.  
  130.         Napster is out of date, get a new version.
  131.         Or also known as gaping security hole.
  132.  
  133.         <version>  = string, the new version number.
  134.         <hostname> = string, hostname of upgrade (http) server
  135.         <filename> = string, filename
  136.  
  137.         Connections are always made to port 80.
  138.  
  139.         The HTTP Request:
  140.                 GET <filename> HTTP/1.0
  141.                 Connection: Keep-Alive
  142.                 Host: <hostname>
  143.  
  144.         Expected HTTP Response.
  145.                 Content-Length: <size>
  146.                 Content-Type: <doesn't matter>
  147.                 <data>
  148.  
  149.         Upgrade file is save as "upgrade.exe".
  150.         And executed as: upgrade.exe UPGRADE "<current.exe>"
  151.  
  152.         As far as I can tell no confirmation is requested by Napster when it
  153.         receives this message.  And immediately start to "auto-upgrade". To keep
  154.         users informed that Napster is doing something potentially very harmful
  155.         to their computer it displays a message saying it's "auto-upgrading".
  156.  
  157.         I think this pretty bad, since all someone has to do is hack a napster
  158.         server et voila a zillion clients at your disposal.
  159.  
  160.         As far as I known this only affects the Win32 2.0b5a Napster client.
  161.         Other clients/versions I don't know.
  162.  
  163.     [This section was contributed by Thomas van der Heijden <thom@bart.nl>
  164.     -ed]
  165.  
  166. 6    new user login [CLIENT]
  167.  
  168.     Format: <nick> <pass> <port> "<client-info>" <speed> <email-address>
  169.  
  170.     This message is used when logging in for the first time to register
  171.     a new nickname.  The client normally checks for an unused nick using
  172.     the "check nickname" (7) message and upon receipt of a "nickname not
  173.     registered" (8) from the server will proceceed to log in with this
  174.     command.
  175.  
  176.     note: this message is similar to the 0x02 message, with the addition    
  177.     of <email-address> on the end
  178.  
  179.     Example:
  180.  
  181.     foo foo 6699 "nap v0.8" 3 email@here.com
  182.  
  183. 7    nick check [CLIENT]
  184.  
  185.     Format: <nick>
  186.  
  187.     Queries the server to see if <nick> is already registered.  This
  188.     message is typically used prior to logging in for the first time to
  189.     check for a valid nickname.
  190.  
  191.     Response to this message is one of 8, 9 or 10
  192.  
  193. 8    nickname not registered [SERVER]
  194.  
  195.     Format: (empty)
  196.  
  197.     The server sends this message in response to the "nick check" (7)
  198.     message to indicate that the specified nickname is not already
  199.     registered and is ok to use.
  200.  
  201. 9    nickname already registered [SERVER]
  202.  
  203.     Format: (empty)
  204.  
  205.     The server sends this message when the nickname the client has
  206.     requested has already been registered by another user
  207.  
  208. 10 (0x0a)    invalid nickname [SERVER]
  209.  
  210.     Format: (empty)
  211.  
  212.     This server sends this message in response to the "check nickname"
  213.     (7) messages when the specified nickname is invalid, usually due to
  214.     bad characters such as spaces or other non-printable characters.
  215.  
  216.         The Napster, Inc. servers only accept (upper- and lower-case) nicks
  217.         comprised of the following:
  218.                abcdefghijklmnopqrstuvwxyz1234567890_[]{}-@^!$
  219.  
  220. 11    ??? [CLIENT]
  221.  
  222.     Format: <nick> <pass>
  223.  
  224.     [returns "parameters are unparsable" -ed]
  225.  
  226. 12    ??? [SERVER]
  227.  
  228.     Format: (empty)
  229.  
  230.     this message is returned in response to message 11 from the client
  231.  
  232. 13    echo??? [SERVER]
  233.  
  234.     Format: <numeric>: [args]
  235.  
  236.     Prior to issuing a login (2) command, the server will echo back the
  237.     received numeric and any arguments of any commands it receives.
  238.  
  239. 14    login options [CLIENT]
  240.  
  241.     NAME:%s ADDRESS:%s CITY:%s STATE:%s PHONE:%s AGE:%s INCOME:%s EDUCATION:%s
  242.  
  243.     Example:
  244.  
  245.     NAME: kev  ADDRESS:  CITY: ephrata  STATE: pa  PHONE:  AGE: 60 or older INCOME: $100,000 or more        EDUCATION: Graduate Degree
  246.  
  247. 100 (0x64)    client notification of shared file [CLIENT]
  248.  
  249.     Format: "<filename>" <md5> <size> <bitrate> <frequency> <time>
  250.  
  251.     <md5> see section "MD5"
  252.     <size> is bytes
  253.     <bitrate> is kbps
  254.     <frequency> is hz
  255.     <time> is seconds
  256.     
  257.     Example:
  258.  
  259.     "generic band - generic song.mp3" b92870e0d41bc8e698cf2f0a1ddfeac7 443332 128 44100 60
  260.  
  261. 102 (0x66)    remove file [CLIENT]
  262.  
  263.     Format: <filename>
  264.  
  265.     client requests to remove file from shared library
  266.  
  267. 110        unshare all files [CLIENT]
  268.  
  269.     Format: (empty)
  270.  
  271.     Notifies the server that the client is no longer sharing any of the
  272.     files previously shared.
  273.  
  274. 200 (0xc8)    client search request [CLIENT]
  275.  
  276.     [FILENAME CONTAINS "artist name"] MAX_RESULTS <max> [FILENAME CONTAINS
  277. "song"] [LINESPEED <compare> <link-type>] [BITRATE <compare> "<br>"] [FREQ
  278. <compare> "<freq>"] [LOCAL_ONLY]
  279.  
  280.         The artist name and the song name are, obviously, treated
  281.                 the same by the server; confirm this for yourself
  282.                 on the windows client.
  283.  
  284.         max is a number; if it is greater than 100, the server will
  285.                 only return 100 results.
  286.  
  287.         <compare> is one of the following:
  288.                 "AT LEAST" "AT BEST" "EQUAL TO"
  289.  
  290.         <link-type> see 0x02 (client login) for a description
  291.  
  292.         <br> is a number, in kbps
  293.  
  294.         <freq> is a sample frequency, in Hz
  295.  
  296.     LOCAL_ONLY causes the server to only search for files from users on
  297.         the same server rather than all linked servers.
  298.  
  299.         The windows client filters by ping time inside the client.
  300.                 It pretty much has to, and it's easy to see the
  301.                 result by setting ping time to at best 100 ms or
  302.                 so, and max search terms to 50.  You'll get back
  303.                 like 3 results, but the client will still tell you
  304.                 that it found "50 results".
  305.  
  306.         Examples:
  307.                 FILENAME CONTAINS "Sneaker Pimps" MAX_RESULTS 75 FILENAME
  308.                          CONTAINS "tesko suicide" BITRATE "AT LEAST" "128"
  309.  
  310.                 MAX_RESULTS 100 FILENAME CONTAINS "Ventolin" LINESPEED
  311.                         "EQUAL TO" 10
  312.  
  313.     [Thanks to Ben Byer <bbyer@rice.edu> for this contribution.  -ed]
  314.  
  315. 201 (0xc9)    search response [SERVER]
  316.  
  317.     "<filename>" <md5> <size> <bitrate> <frequency> <length> <nick> <ip>
  318.     <link-type> [weight]
  319.  
  320.     <md5> see secton "MD5"
  321.     <size> is file size in bytes
  322.     <bitrate> is mp3 bit rate in kbps
  323.     <frequency> is sample rate in hz
  324.     <length> is the play length of the mp3 in seconds
  325.     <nick> the person sharing the file
  326.     <ip> is an unsigned long integer representing the ip address of the
  327.         user with this file
  328.     <link-type> see message client login (2) message for a description
  329.     [weight]    a weighting factor to allow the client to sort the
  330.                     list of results.  positive values indicate a "better"
  331.             match, negative values indicate a "worse" match.
  332.             If not present, the weight should be considered to be
  333.             0.
  334.  
  335.     Example:
  336.  
  337.     "random band - random song.mp3" 7d733c1e7419674744768db71bff8bcd 2558199 128 44100 159 lefty 3437166285 4
  338.  
  339. 202 (0xca)    end of search response from server [SERVER]
  340.  
  341.     Format: (empty)
  342.  
  343. 203 (0xcb)    download request [CLIENT]
  344.  
  345.     Format: <nick> "<filename>"
  346.  
  347.     client requests to download <filename> from <nick>.  client expects
  348.     to make an outgoing connection to <nick> on their specified data
  349.     port.
  350.  
  351.     Example:
  352.  
  353.     mred "C:\Program Files\Napster\generic cowboy song.mp3"
  354.  
  355.     SEE ALSO: 500 alternate download request
  356.  
  357. 204 (0xcc)    download ack [SERVER]
  358.  
  359.     <nick> <ip> <port> "<filename>" <md5> <linespeed>
  360.  
  361.     server sends this message in response to a 203 request.
  362.  
  363.     <nick> is the user who has the file
  364.     <ip> is an unsigned long integer representing the ip address
  365.     <port> is the port <nick> is listening on
  366.     <filename> is the file to retrieve
  367.     <md5> is the md5 sum
  368.     <linespeed> is the user's connection speed (see login(2))
  369.  
  370.     Example:
  371.  
  372.     lefty 4877911892 6699 "generic band - generic song.mp3" 10fe9e623b1962da85eea61df7ac1f69 3
  373.  
  374. 205 (0xcd)    private message to/from another user [CLIENT, SERVER]
  375.  
  376.     <nick> <message>
  377.  
  378.     note the same type is used for a client sending a msg or recieving one
  379.  
  380.     [Commentary: this message causes problems if you consider linking
  381.     servers together.  With the current one server situation, the server
  382.     just rewrites the message it receives with the name of the client that
  383.     sent it and passes it to the recipient client.  However, in the case
  384.     where the recipient and sender are not on the same server, there is
  385.     loss of information without encapsulating it.  It would have been
  386.     better to put both the sender and recipient because if the servers
  387.     are ever linked they will have to make a new message type for this
  388.     situation.  -ed]
  389.  
  390. 206 (0xce)    get error [SERVER]
  391.  
  392.     <nick> "<filename>"
  393.  
  394.     the server sends this message when the file that the user has
  395.     requested to download is unavailable (such as the user is not logged
  396.     in).
  397.  
  398. 207 (0xcf)    add hotlist entry [CLIENT]
  399.  
  400.     <user>
  401.  
  402.     This message is used to add additional entries to the client's
  403.     hotlist.  The server will send 209 and 210 messages when a user
  404.     on the hotlist has logged in or out, respectively.
  405.  
  406. 208 (0xd0)    hotlist [CLIENT]
  407.  
  408.     <user>
  409.  
  410.     This message is used to send the initial list of hotlist entries
  411.     during the initial login process.  It is normally send prior to
  412.     to the add file (100) commands.  To add more entries to the hotlist
  413.     after the initial list is sent, clients should use the 207 message
  414.     instead.
  415.  
  416. 209 (0xd1)    user signon [SERVER]
  417.  
  418.     <user> <speed>
  419.  
  420.     server is notifying client that a user in their hotlist, <user>,
  421.     has signed on the server with link <speed>
  422.  
  423. 210 (0xd2)    user signoff [SERVER]
  424.  
  425.     <user>
  426.  
  427.     server is notifying client that a user on their hotlist, <user>, has
  428.     signed off the server.
  429.  
  430.     this message is also sent by the server when the client attempts to
  431.     browse a nonexistent client.  [why don't they just use 404 for
  432.     this? -ed]
  433.  
  434. 211 (0xd3)    browse a user's files [CLIENT]
  435.  
  436.     <nick>
  437.  
  438.     the client sends this message when it wants to get a list of the files
  439.     shared by a specific client
  440.  
  441. 212 (0xd4)    browse response [SERVER]
  442.  
  443.     <nick> "<filename>" <md5> <size> <bitrate> <frequency> <time>
  444.  
  445.     <nick> is the user contributing the file
  446.     <filename> is the mp3 file contributed
  447.     <md5> is the has of the mp3 file
  448.     <size> is the file size in bytes
  449.     <bitrate> is the mp3 bitrate in kbps
  450.     <frequence> is the sampling frequency in Hz
  451.     <time> is the play time in seconds
  452.  
  453.     Example:
  454.  
  455.     foouser "generic band - generic song.mp3" b92870e0d41bc8e698cf2f0a1ddfeac7 443332 128 44100 60
  456.  
  457. 213 (0xd5)    end of browse list [SERVER]
  458.  
  459.     <nick> [ip]
  460.  
  461.     indicates no more entries in the browse list for <user>.  <ip> gives
  462.     the client's IP address.
  463.  
  464. 214 (0xd6)    server stats [CLIENT, SERVER]
  465.  
  466.     client: no data
  467.     server: <users> <# files> <size>
  468.  
  469.     <size> is approximate total library size in gigabytes
  470.     this message is sent by the server occasionaly without request
  471.  
  472.     Example:
  473.  
  474.     553 64692 254
  475.  
  476. 215 (0xd7)    request resume [CLIENT]
  477.  
  478.     <checksum> <filesize>
  479.  
  480.     client is requesting a list of all users which have the file with
  481.     the characteristics.  the server responds with a list of 216 messages
  482.     for each match, followed by a 217 message to terminate the list
  483.  
  484. 216 (0xd8)    resume search response [SERVER]
  485.  
  486.     <user> <ip> <port> <filename> <checksum> <size> <speed>
  487.  
  488.     this message contains the matches for the resume request (215).  the
  489.     list is terminated by a 217 message.
  490.  
  491. 217 (0xd9)    end of resume search list [SERVER]
  492.  
  493.     no data.
  494.  
  495.     this messag terminates a list of 216 messages initiated by a 215
  496.     client request
  497.  
  498. 218 (0xda)    downloading file [CLIENT]
  499.  
  500.     no body.
  501.  
  502.     client sends this message to the server to indicate they are in the
  503.     process of downloading a file.  this adds 1 to the download count
  504.     which the server maintains.
  505.  
  506. 219 (0xdb)    download complete [CLIENT]
  507.  
  508.     no body.
  509.  
  510.     client sends this message to the server to indicate they have
  511.     completed the file for which a prior 218 message was sent.  this
  512.     subtracts one from the download count the server maintains
  513.  
  514. 220 (0xdc)    uploading file [CLIENT]
  515.  
  516.     no body.
  517.  
  518.     client sends this message to indicate they are uploading a file.
  519.     this adds one to the upload count maintained by the server.
  520.  
  521. 221 (0xdd)    upload complete [CLIENT]
  522.  
  523.     no body.
  524.  
  525.     client sends this message when they are finished uploading a file.
  526.     this subtracts one from the upload count maintained by the server.
  527.  
  528. 300 (0x12c)    optional ports [CLIENT]
  529.  
  530.     <port>
  531.  
  532.     This command allows the client to specify optional ports to try for
  533.     data connections if the one currently in use is unreachable by other
  534.     parties.
  535.  
  536. 301 (0x12d)    hotlist ack [SERVER]
  537.  
  538.     <user>
  539.  
  540.     server is notifying client that <user> has successfully be added to
  541.     their hotlist
  542.  
  543. 302 (0x12e)    hotlist error [SERVER]
  544.  
  545.     <user>
  546.  
  547.     server is notifying client that it was unable to add <user> to their
  548.     hotlist.  [can you only add registered nicks to your hotlist? -ed]
  549.  
  550. 303 (0x12f)    remove user from hotlist [CLIENT]
  551.  
  552.     <user>
  553.  
  554.     client is notifying the server that it no longer wishes to request
  555.     notifications about <user> when they sign on or off the server.  no
  556.     response is sent in return.
  557.  
  558. 310    ??? [CLIENT, SERVER]
  559.  
  560.     client: no data
  561.     server: 0
  562.  
  563.     unknown command.  server returns 0 regardless of any parameters
  564.  
  565. 316    client disconnect??? [CLIENT, SERVER]
  566.  
  567.     client: no data
  568.     server: 0
  569.  
  570.     The server sends this message with a value of `0' when the client is
  571.     about to be disconnected.
  572.  
  573.     It is unkonwn what this command does when issued by the client.  The
  574.     server appears to send the 316 message without disconnected the client
  575.     in this case.
  576.  
  577.     [the server seems to send this message if you send it a numeric
  578.     greater than 1000.  the server will also disconnect you after
  579.     sending this message.  -ed]
  580.  
  581. 320 (0x140)    user ignore list [CLIENT, SERVER]
  582.  
  583.     client: no data
  584.     server: <count>
  585.  
  586.     client request to display the list of ignored users.
  587.     server returns the number of users being ignored
  588.  
  589. 321 (0x141)    user ignore list entry [SERVER]
  590.  
  591.     <user>
  592.  
  593.     server sends each ignored nick in response to a 320 request.  the
  594.     list is terminated by a 320 message with the number of ignored users.
  595.  
  596. 322 (0x142)    add user to ignore list [CLIENT, SERVER]
  597.  
  598.     <user>
  599.  
  600.     server acks the request by returning the nick
  601.  
  602. 323 (0x143)    remove user from ignore list [CLIENT]
  603.  
  604.     <user>
  605.  
  606.     server acks the request by returning the nick to be removed from
  607.     the ignore list.
  608.  
  609. 324 (0x144)    user is not ignored [SERVER]
  610.  
  611.     <user>
  612.  
  613.     server indicates that <user> is not currently ignored in response to
  614.     a 323 request.
  615.  
  616. 325 (0x145)    user is already ignored [SERVER]
  617.  
  618.     <user>
  619.  
  620.     server indicates the specified user is already on the user's ignore
  621.     list
  622.  
  623. 326 (0x146)    clear ignore list [CLIENT, SERVER]
  624.  
  625.     client: no data.
  626.     server: <count>
  627.  
  628.     client requests the server clear its ignore list.  server returns the
  629.     number of entries removed from the ignore list.
  630.  
  631. 330 (0x14a)    blocked ip list [CLIENT]
  632.  
  633. 332 (0x14c)    block ip [CLIENT]
  634.  
  635. 333 (0x14d)    unblock ip [CLIENT]
  636.  
  637. 400 (0x190)    join channel [CLIENT]
  638.  
  639.     <channel-name>
  640.  
  641.     the client sends this command to join a channel
  642.  
  643. 401 (0x191)    part channel [CLIENT, SERVER]
  644.  
  645.     <channel-name>
  646.  
  647.     The client sends this command to part a channel.  Server sends this
  648.     message to indicate that the client has parted the channel.  Note
  649.     that this is sometimes sent even when the client has not requested,
  650.     so a client _must_ be prepared to accept it at any time.
  651.  
  652. 402 (0x192)    send public message [CLIENT]
  653.  
  654.     <channel> <message>
  655.  
  656. 403 (0x193)    public message [SERVER]
  657.  
  658.     <channel> <nick> <text>
  659.  
  660.     this message is sent by the server when a client sends a public message
  661.     to a channel.
  662.  
  663.     Example:
  664.  
  665.     80's espinozaf hello...hola
  666.  
  667. 404 (0x194)    error message [SERVER]
  668.  
  669.     <text>
  670.  
  671.     This message is used to send general error messages to a client that
  672.     is logged in.  Note: Message 0 is only sent during the login process.
  673.  
  674.     Examples:
  675.  
  676.     User nosuchuser is not currently online.
  677.     Channel #nosuchchannel does not exist!
  678.     permission denied
  679.     ping failed, blah is not online
  680.  
  681. 405 (0x195)    join acknowledge [SERVER]
  682.  
  683.     <channel>
  684.  
  685.     the server sends this message to the client to acknowlege that it
  686.     has joined the requested channel (400)
  687.     
  688. 406 (0x196)    join message [SERVER]
  689.  
  690.     <channel> <user> <sharing> <link-type>
  691.  
  692.     <user> has joined <channel>
  693.  
  694.     Example:
  695.  
  696.     80's WilmaFlinstone 12 2
  697.  
  698. 407 (0x197)    user parted channel [SERVER]
  699.  
  700.     <channel> <nick> <sharing> <linespeed>
  701.  
  702.     Example:
  703.  
  704.     80's DLongley 23 7
  705.  
  706. 408 (0x198)    channel user list entry [SERVER]
  707.  
  708.     this message is identical to the join (406) message.  the server will
  709.     send the list of users in the channel prior to the client join command
  710.     in this message.  joins that occur after the client has joined will
  711.     be noted by a 406 message.
  712.  
  713. 409 (0x199)    end of channel user list [SERVER]
  714.  
  715.     <channel>
  716.  
  717.     this message is sent by the server to indicate it has sent all informati    about the users in a channel
  718.  
  719. 410 (0x19a)    channel topic [CLIENT, SERVER]
  720.  
  721.     <channel> <topic>
  722.  
  723.     sent when joining a channel or a new topic is set.  a client requesting
  724.     topic change also uses this message.
  725.  
  726.     [why didn't they put a field to indicate WHO changed the topic?  as
  727.     it is now you can only tell that it was changed.  -ed]
  728.  
  729. 420 (0x1a4)    channel ban list [CLIENT, SERVER]
  730.  
  731.     Format: <channel>
  732.  
  733.     This command is used by clients to request the list of channel bans,
  734.     and by the server to indicate the end of the channel ban list for
  735.     a channel (also see 421).
  736.  
  737. 421 (0x1a5)    channel ban list entry [SERVER]
  738.  
  739. 422 (0x1a6)    channel ban [CLIENT]
  740.  
  741.     <channel> <user|ip> [ "<reason>" ]
  742.  
  743. 423 (0x1a7)    channel unban [CLIENT]
  744.  
  745.     <channel> <user|ip> [ "<reason>" ]
  746.  
  747. 424 (0x1a8)    channel ban clear [CLIENT]
  748.  
  749.     Format: <channel>
  750.  
  751. 425    channel motd (alternate topic (?)) [SERVER]
  752.  
  753.     Format: <message>
  754.  
  755.     [The server sends this command when a user joins one of the
  756.     predefined channels.  It seems to send a default message if the
  757.     topic for the channel is the default, otherwise it sends the current
  758.     channel topic.  -ed]
  759.  
  760. 500 (0x1f4)    alternate download request [CLIENT]
  761.  
  762.     <nick> "<filename>"
  763.  
  764.     requests that <nick> make an outgoing connection to the requesters
  765.     client and send <filename>.  this message is for use when the
  766.     person sharing the file can only make an outgoing tcp connection
  767.     because of firewalls blocking incoming messages.  this message should
  768.     be used to request files from users who have specified their data
  769.     port as 0 in their login message
  770.  
  771. 501 (0x1f5)    alternate download ack [SERVER]
  772.  
  773.     <nick> <ip> <port> "<filename>" <md5> <speed>
  774.  
  775.     this message is sent to the uploader when their data port is set to
  776.     0 to indicate they are behind a firewall and need to push all data
  777.     outware.  the uploader is responsible for connecting to the
  778.     downloader to transfer the file.
  779.  
  780. 600 (0x258)    request user's link speed [CLIENT]
  781.  
  782.     <nick>
  783.  
  784. 601 (0x259)    link speed response [SERVER]
  785.  
  786.     <nick> <linespeed>
  787.  
  788. 602 (0x25a)    ??? [CLIENT]
  789.  
  790.     <?>
  791.  
  792.     server returns a 404 with "*gulp* Drink milk, it does a body good!"
  793.  
  794. 603 (0x25b)    whois request [CLIENT]
  795.  
  796.     <nick>
  797.  
  798. 604 (0x25c)    whois response [SERVER]
  799.  
  800.     <nick> "<user-level>" <time> "<channels>" "<status>" <shared>
  801.     <downloads> <uploads> <link-type> "<client-info>" [ <total downloads>
  802.     <total_uploads> <ip> <connecting port> <data port> <email> ]
  803.  
  804.     <user-level> is one of "User", "Moderator", "Admin" or "Elite"
  805.     <time> is seconds this user has been connected
  806.     <channels> is the list of channels the client is a member of, each
  807.         separated by a space (ASCII 32)
  808.     <status> is one of "Active", "Inactive" (offline) or "Remote" (on a
  809.         different server)
  810.     <shared> is number of files user has available for download
  811.     <downloads> is the current number of downloads in progress
  812.     <uploads> is the current number of uploads in progress
  813.     <link-type> see 0x02 (client login) above
  814.     <client-info> see 0x02 (client login) above
  815.  
  816.     The following fields are displayed for user level moderator and
  817.     above:
  818.  
  819.     <total uploads>
  820.     <total downloads>
  821.     <ip>            note: can be "unavailable"
  822.     <connecting port>
  823.     <data port>
  824.     <email>            note: can be unavailable
  825.  
  826.     Example:
  827.  
  828.     lefty "User" 1203 "80's " "Active" 0 0 0 3 "nap v0.8"
  829.  
  830. 605 (0x25d)    whowas response [SERVER]
  831.  
  832.     <user> <level> <last-seen>
  833.  
  834.     if the user listed in a 603 request is not currently online, the
  835.     server sends this message.
  836.  
  837.     <user> is the user for which information was requested
  838.     <level> is the user's last known userlevel (user/mod/admin)
  839.     <last-seen> is the last time at which this user was seen, measured
  840.         as seconds since 12:00am on January 1, 1970 (UNIX time_t).
  841.  
  842. 606 (0x25e)    change user level [CLIENT]
  843.  
  844.     <nick> <level>
  845.  
  846.     changes the privileges for <nick> to <level>.  client must be admin
  847.     level to execute this request
  848.  
  849.     [I have not verified this message since I don't have admin status
  850.     on any of the servers.  -ed]
  851.  
  852. 607 (0x25f)    upload request [SERVER]
  853.  
  854.     <nick> "<filename>" <speed>
  855.  
  856.     this message is used to notify the client that user <nick> has
  857.     requested upload of <filename>
  858.  
  859.     Example:
  860.  
  861.     lefty "generic band - generic song.mp3" 7
  862.  
  863. 608 (0x260)    accept upload request [CLIENT]
  864.  
  865.     <nick> "<filename>"
  866.  
  867.     client is notifying server that upload of <filename> to <nick> is
  868.     accepted, and that the requesting client may begin download
  869.  
  870.     Example:
  871.  
  872.     lefty "generic band - generic song.mp3"
  873.  
  874. 609 (0x261)     accept failed [SERVER]
  875.  
  876.         <nick> "<filename>"
  877.  
  878.     this message is sent by the server when the client that the file was
  879.     requested from does not accept the upload request.
  880.  
  881. 610 (0x262)    kill (disconnect) a user [CLIENT]
  882.  
  883.     <nick> [ "<reason>" ]
  884.  
  885.     client request to disconnect a user.
  886.  
  887. 611 (0x263)    nuke a user [CLIENT]
  888.  
  889.     <nick>
  890.  
  891.     client request to delete account for <nick>
  892.  
  893. 612 (0x264)    ban user [CLIENT]
  894.  
  895.     <nick | ip> [ "<reason>" ]
  896.  
  897.     client request to place a ban on either a specific nickname or
  898.     an ip address
  899.  
  900. 613 (0x265)    set data port for user [CLIENT, SERVER]
  901.  
  902.     client: <user> <port>
  903.     server: <port>
  904.  
  905.     This command is used by administrators to request that another
  906.     client set the port used for data transfers to <port>.  The server
  907.     sends a message with the requested port number to the target
  908.     client.  NOTE: the target client can change its port number to
  909.     whatever it wishes using the 703 command.
  910.  
  911. 614 (0x266)    unban user [CLIENT]
  912.  
  913.     Format: <nick | ip> [ "<reason>" ]
  914.  
  915. 615 (0x267)    show bans for server [CLIENT]
  916.  
  917.     Format: (empty)
  918.  
  919.     client requests the list of banned ips for the current server
  920.  
  921. 616 (0x268)    (ip?) ban list entry [SERVER]
  922.  
  923.     Format: <ip> <nick> "<reason>" <time> <n>
  924.  
  925.     <ip> is the string version of the ip banned
  926.     <nick> is the user setting the ban
  927.     <reason> is the reason given
  928.     <time> is the time_t when the ban was set
  929.     <n> is ???.  value is either 0 or 1
  930.  
  931.     This message is sent in response to the 615 client request, one
  932.     for each ban.  The list is terminated with a 0 length 615 message
  933.     from the server.
  934.  
  935.     Example:
  936.     
  937.     207.172.245. valkyrie "DoS exploit" 947304224 0
  938.  
  939. 617 (0x269)    list channels [CLIENT, SERVER]
  940.  
  941.     Format: (empty)
  942.  
  943.     client requests a list of channels on the server.  server responds
  944.     with 618/617
  945.  
  946.     server indicates end of channel list using this message.
  947.  
  948. 618 (0x26a)    channel list entry [SERVER]
  949.  
  950.     Format: <channel-name> <number-of-users> <topic>
  951.  
  952.     this is the server response to a 617 client request, one for each
  953.     channel.
  954.  
  955.     Example:
  956.  
  957.     Help 50 OpenNap help channel
  958.  
  959. 619 (0x26b)    queue limit [CLIENT]
  960.  
  961.     Format: <nick> "<filename>" <n>
  962.  
  963.     a client may limit the number of downloads from a particular client.
  964.     once the limit for a particular user has been reached, the uploading
  965.     client can send this message to notify the downloader that they
  966.     have hit the limit and can't have any more simultaneous downloads.
  967.     <nick> is the user who hit the limit, <filename> is the file they
  968.     were trying to download when they hit the limit, and <n> is the
  969.     number of simultaneous downloads allowed.
  970.  
  971.     Example:
  972.  
  973.     joebob "C:\MP3\Generic Band - Generic Song.mp3" 3
  974.  
  975. 620 (0x26c)    queue limit [SERVER]
  976.  
  977.     <nick> "<filename>" <filesize> <digit>
  978.  
  979.     This message is sent by the server in response to the 619 client
  980.     request, when one user needs to notify another that they have
  981.     reached the maximum allowed simultaneous downloads.  When the server
  982.     recieves the 619 request from the uploading client, it sends the 620
  983.     message to the downloading client.  The only difference in format is
  984.     the addition of the <nick> field in the 620 message which specifies
  985.     the username of the uploading agent which is notifying the
  986.     downloader that the queue is full.
  987.  
  988.     Example:
  989.  
  990.     joebob "C:\MP3\Generic Band - Generic Song.mp3" 1234567 3
  991.  
  992. 621 (0x26d)    message of the day [CLIENT, SERVER]
  993.  
  994.     <text>
  995.  
  996.     Server: each 621 message contains a single line of text
  997.  
  998.     Client: client sends a 621 command with no data to request the
  999.     motd be sent.  The server will usually send this automatically after
  1000.     a user logs in, so this command allows a user to reread it upon
  1001.     request.
  1002.  
  1003. 622 (0x26e)    muzzle a user [CLIENT]
  1004.  
  1005.     <nick> [ "<reason>" ]
  1006.  
  1007.     client requests that <nick> not be allowed to send public messages
  1008.  
  1009. 623 (0x26f)    unmuzzle a user [CLIENT]
  1010.  
  1011.     <nick> [ "<reason>" ]
  1012.  
  1013.     client requests that the enforced silence on <nick> be lifted
  1014.  
  1015. 624 (0x270)    un-nuke a user [CLIENT]
  1016.  
  1017.     <user>
  1018.  
  1019. 625 (0x271)    change a user's linespeed [CLIENT]
  1020.  
  1021.     <user> <speed>
  1022.  
  1023. 626 (0x272)    data port error [CLIENT, SERVER]
  1024.  
  1025.     <user>
  1026.  
  1027.     When a downloading client detects that the uploader's data port
  1028.     is unreachable, it should send a 626 message to the server with
  1029.     the nick of the user for which the connection failed.  The server
  1030.     then relays the message to the uploader, substituing the
  1031.     downloader's nickname in the message.
  1032.  
  1033. 627 (0x273)    operator message [CLIENT, SERVER]
  1034.  
  1035.     client: <text>
  1036.     server: <nick> <text>
  1037.  
  1038.     client request to send a message to all admins/moderators
  1039.  
  1040. 628 (0x274)    global message [CLIENT, SERVER]
  1041.  
  1042.     client: <text>
  1043.     server: <nick> <text>
  1044.  
  1045.     client request send a message to all users
  1046.  
  1047. 629 (0x275)    banned users [SERVER]
  1048.  
  1049.     Format: <nick>
  1050.  
  1051.     when displaying the ban list for the server, this message is used
  1052.     to indicate banned nicknames.
  1053.  
  1054. 630-639 missing
  1055.  
  1056. 640    direct browse request [CLIENT, SERVER]
  1057.  
  1058.     Client: <nick>
  1059.     Server: <nick> [ip port]
  1060.  
  1061.     Client: request files for <nick>
  1062.     Server: <nick> is requesting your files.  optionally, <ip> and
  1063.         <port> are given if the client getting browsed is firewalled
  1064.  
  1065.     This message is sent to initiate a direct client to client browsing of
  1066.     shared files.
  1067.  
  1068.     See section 5.3.
  1069.  
  1070. 641    direct browse accept [CLIENT, SERVER]
  1071.  
  1072.     Client: <nick>
  1073.     Server: <nick> <ip> <port>
  1074.  
  1075.     The client to be browsed sends this message back to the server to
  1076.     indicate it is willing to accept a direct browse from <nick>.
  1077.  
  1078.     The server sends this message to the requestor of the browse to
  1079.     indicate where it should connect in order to do a direct browse from
  1080.     <nick>.
  1081.  
  1082.     See section 5.3
  1083.  
  1084. 642    direct browse error [SERVER]
  1085.  
  1086.     <nick> "message"
  1087.  
  1088.     Server sends this messags in response to a 640 request if there is an
  1089.     error (eg. both clients are firewalled, or the browsee is not sharing
  1090.     any files).
  1091.  
  1092.     See section 5.3
  1093.  
  1094. 643-649    missing
  1095.  
  1096. 650-651    ??? [CLIENT]
  1097.  
  1098.     permission denied.
  1099.  
  1100. 652 (0x28c)    cloak user [CLIENT]
  1101.  
  1102.     sets the current user to "invisible"
  1103.  
  1104. 653-699    missing.
  1105.  
  1106. 700    change link speed [CLIENT]
  1107.  
  1108.     <speed>
  1109.  
  1110.     client is notifying server that its correct link speed is <speed>,
  1111.     in the range 0-10 (see the login message for details).
  1112.  
  1113. 701    change user password [CLIENT]
  1114.  
  1115.     <password>
  1116.  
  1117.     client wishes to change their password
  1118.  
  1119. 702    change email address [CLIENT]
  1120.  
  1121.     <email address>
  1122.  
  1123.     client wishes to change their email address
  1124.  
  1125. 703    change data port [CLIENT]
  1126.  
  1127.     <port>
  1128.  
  1129.     client is changing the data port being listened on for file
  1130.     transfers
  1131.  
  1132. 704-747    missing.
  1133.  
  1134. 748    login attempt [SERVER]
  1135.  
  1136.     the server sends this message to a logged in client when another
  1137.     client attempts to log in with the same nickname.
  1138.  
  1139. 749    missing.
  1140.  
  1141. 750 (0x2ee)    server ping [CLIENT, SERVER]
  1142.  
  1143.         server: none
  1144.         client: <user>
  1145.  
  1146.         Napster 2.0b5a sends the username in a response to a 750 from the
  1147.     server.
  1148.  
  1149.     [server returns an empty 750 command in response. server ping? -ed]
  1150.  
  1151. 751 (0x2ef)    ping user [CLIENT, SERVER]
  1152.  
  1153.     <user>
  1154.  
  1155.     client is attempting to determine if <user>'s connection is alive
  1156.  
  1157. 752 (0x2f0)    pong response [CLIENT, SERVER]
  1158.  
  1159.     <user>
  1160.  
  1161.     this message is sent in response to the the 751 (PING) requeset
  1162.  
  1163. 753 (0x2f1)    change password for another user [CLIENT]
  1164.  
  1165.     <user> <password> "<reason>"
  1166.  
  1167.     allows an administrator to change the password for another user
  1168.  
  1169. 754-769    missing.
  1170.  
  1171. 770    ??? [CLIENT]
  1172.  
  1173.     permission denied.
  1174.  
  1175. 771    ??? [CLIENT]
  1176.  
  1177.     permission denied.
  1178.  
  1179. 772-799    missing.
  1180.  
  1181. 800 (0x320)    reload config [CLIENT]
  1182.  
  1183.     <config variable>
  1184.  
  1185.     resets configuration parameter to its default value
  1186.  
  1187. 801 (0x321)    server version [CLIENT]
  1188.  
  1189.     no data.
  1190.  
  1191.     client request's a server's version
  1192.  
  1193. 802-804    missing.
  1194.  
  1195. 805    ???
  1196.  
  1197.     [returns permission denied. -ed]
  1198.  
  1199. 810 (0x32a)    set config [CLIENT]
  1200.  
  1201.     <config string>
  1202.  
  1203.     request a change in server configuration variables
  1204.  
  1205. 811 (0x32b)    ???    [CLIENT]
  1206.  
  1207.     [returns permission denied. -ed]
  1208.  
  1209. 820 (0x334)    clear channel [CLIENT]
  1210.  
  1211.     <channel>
  1212.  
  1213.     remove all users from the specified channel
  1214.  
  1215. 821 (0x335)    redirect client to another server [CLIENT, SERVER]
  1216.  
  1217.     client: <user> <server> <port>
  1218.     server: <server> <port>
  1219.     
  1220.     This command allows an administrator to redirect clients to another
  1221.     server.
  1222.  
  1223. 822 (0x336)    cycle client [CLIENT, SERVER]
  1224.  
  1225.     client: <user> <metaserver>
  1226.     server: <metaserver>
  1227.  
  1228.     This commands allows an administrator to make a client restart the
  1229.     login process by first connecting to the metaserver (redirector) at
  1230.     <host>.
  1231.  
  1232. 823 (0x337)    set channel level [CLIENT]
  1233.  
  1234.     <channel> <level>
  1235.  
  1236.     Sets <channel> such that users must be at least <level> in order to
  1237.     enter the channel
  1238.  
  1239. 824 (0x338)    emote [CLIENT, SERVER]
  1240.  
  1241.     client: <channel> "<text>"
  1242.     server: <channel> <user> "<text>"
  1243.  
  1244.     A variation of the public message command to indicate an action by
  1245.     the user.  Often implemented as the "/me" command in IRC clients.
  1246.  
  1247. 825 (0x339)    user list entry [SERVER]
  1248.  
  1249.     <channel> <user> <files shared> <speed>
  1250.  
  1251.     an 825 message is sent for each user in the channel specified by the
  1252.     830 message
  1253.  
  1254.     Example:
  1255.  
  1256.     Help testor3 0 3
  1257.  
  1258.     [This appears to be exactly the same format as the 408 message.  -ed]
  1259.  
  1260. 826 (0x33a)    channel limit [CLIENT]
  1261.  
  1262.     <channel> <limit>
  1263.  
  1264.     sets the maximum number of users that may enter a channel.  <limit>
  1265.     is an integer value between 0 and 999999999.  setting it higher that
  1266.     this results in the limit being set to -1.  by default, created
  1267.     channels have a limit of 200.  there appears to be no restriction on
  1268.     any channel member changing the limit, and no notification is given
  1269.  
  1270. 827 (0x33b)    show all channels [CLIENT, SERVER]
  1271.  
  1272.     no data.
  1273.  
  1274.     client request to show all channels, including "hidden" channels.
  1275.     the server also sends this message to terminate
  1276.  
  1277. 828 (0x33c)    channel list [SERVER]
  1278.  
  1279.     <channel> <users> <n1> <level> <limit> "<topic>"
  1280.  
  1281.     the server sends a list of 828 commands, one for each channel,
  1282.     including "hidden" channels that don't show up in the normal channel
  1283.     list.
  1284.  
  1285.     <level> is the mimimum user level required for entry into a channel
  1286.     <limit> is the max number of users allowed in a channel
  1287.  
  1288.     <n1> is either 0 or 1.  seems to be 1 if the channel was user
  1289.     created, or 0 if a predefined channel???
  1290.  
  1291. 829 (0x33d)    kick user from channel [CLIENT]
  1292.  
  1293.     <channel> <user> [ "<reason>" ]
  1294.  
  1295. 830 (0x33e)    list users in channel [CLIENT, SERVER]
  1296.  
  1297.     <channel>
  1298.  
  1299.     client requests a list of all users in <channel>.  server responds
  1300.     with a 825 response for each user, followed by an 830 response with
  1301.     no data [why didn't they just use the 409 message? -ed]
  1302.  
  1303. 831 (0x33f)    global user list [CLIENT]
  1304.  
  1305.     [returns permission denied.  -ed]
  1306.  
  1307. 832-869    missing.
  1308.  
  1309. 870    add files by directory [CLIENT]
  1310.  
  1311.     Format: "<directory>" "<file>" <md5> <size> <bitrate> <freq> <duration>
  1312.     [ ... ]
  1313.  
  1314.     This command allows a client to share multiple files in the same
  1315.     directory as a shortcut to multiple 100 (share file) commands.
  1316.     <directory> is the path which should be prepended to all the given
  1317.     filenames in the rest of the command.  <file> is the name of the file
  1318.     to share *without* its directory component.  When other clients do a
  1319.     browse/share, the real path will be reported as <directory>/<file>.
  1320.  
  1321.     The portion of this command after the <directory> may be repeated as
  1322.     many times as necessary for files in the same directory. NOTE: most
  1323.     servers will not accept commands of length longer than 2048 bytes
  1324.     so you still may need to break up the files into multiple commands
  1325.     if there are many files in a single directory.
  1326.  
  1327. 871-899    missing.
  1328.  
  1329. 900     connection test [SERVER]
  1330.  
  1331.         <ip> <port> <data>
  1332.  
  1333.         <ip>   - string,  ip address to connect to.
  1334.         <port> - integer, port to connect to
  1335.         <data> - string,  data to send to server.
  1336.  
  1337.         Try to connect to <ip> on <port> for atmost 1000 seconds.  If the
  1338.         connection succeeds send the <data> to target.
  1339.  
  1340.     [reported by Thomas van der Heijden <thom@bart.nl>]
  1341.  
  1342. 901     listen test [SERVER]
  1343.  
  1344.         <port> <timeout> <data>
  1345.  
  1346.         <port>    - integer, port to listen on
  1347.         <timeout> - integer, time to wait for connection in seconds
  1348.         <data>    - string,  data to send after connection has been made.
  1349.  
  1350.         Listen on <port> for <timeout> seconds. If a connection arrives,
  1351.         return <data> to sender.
  1352.  
  1353.     [reported by Thomas van der Heijden <thom@bart.nl>]
  1354.  
  1355. 920    ??? [CLIENT]
  1356.  
  1357.     Format: 1
  1358.  
  1359.     This is sent by the BETA8 client prior to login.  Purpose unknown.
  1360.  
  1361. 3.  MD5
  1362.  
  1363. It looks like the vast majority of the files are hashed using the first
  1364. 299,008 bytes of the file.  There have been some cases where the hash
  1365. matches at 300,032 bytes, but no correlation has been drawn as to when that
  1366. happens.  The speculation at this point is that it might have to do with
  1367. the existence of a ID3v2 tag, or perhaps the file was sampled at 48kHz...?
  1368.  
  1369. The current method seems to be: skip id3v2, seek to frame sync and hash.
  1370.  
  1371. Note: the linux nap client (versions 0.7 - 0.9) seem to hash exactly 300,000
  1372. bytes, which is NOT what the official windows client does.
  1373.  
  1374. 5.  Client-Client Protocol
  1375.  
  1376. File transfer occur directly between clients without passing through the
  1377. server.  There are four transfer modes, upload, download, firewalled upload,
  1378. firewalled download.  The normal method of transfer is that the client
  1379. wishing to download a file makes a TCP connection to the client holding the
  1380. file on their data port.  However, in the case where the client sharing the
  1381. file is behind a firewall, it is necessary for them to "push" the data by
  1382. making a TCP connection to the downloader's data port.
  1383.  
  1384. 5.1  Normal Downloading
  1385.  
  1386. Regardless of which mode, the downloading client will first issue either a 
  1387. search(200) or browse(211) command to the server.  This returns a list of
  1388. files and information on the client sharin the file.  To request a download,
  1389. a get(203) request is sent to the server.  The server will respond with
  1390. a get ack(204) containing more detailed information.
  1391.  
  1392. This is the point at which the different methods diverge.  If the 204 get
  1393. ack says that the remote clients data port is 0, you must send a 500 request
  1394. to the server requesting that the remote client send the data to you.  In
  1395. this case you wait for the remote client to connect to your own data port.
  1396.  
  1397. In the case where the sharing client is not firewalled, you make a TCP
  1398. connection to the data port specified in the 204 message from the server.
  1399. The remote client should accept the connection and immediately send one
  1400. ASCII char, `1' (ASCII 49).  Once you read this char, you send a request
  1401. for the file you wish to download.  First send the string "GET" in a single
  1402. packet, then send
  1403.     <mynick> "<filename>" <offset>
  1404. where <mynick> is your napster user name, <filename> is the file you wish to
  1405. download, and <offset> if the byte offst in the file to begin the transfer
  1406. at (if you are downloading for the first time, and not resuming a prior
  1407. transfer, you should uses 0 to start at the beginning of the file).
  1408.  
  1409. The remote client will then return the file size, or an error message such
  1410. as "INVALID REQUEST" or "FILE NOT SHARED".  Note that the file size is not
  1411. terminated in any special way, and the best way to figure out the size is to
  1412. keep reading until you hit a character that is not a digit (it will usually
  1413. be 0xff which is the start of the MP3 frame sync header, but if a ID3v2
  1414. tag is present it might look different).  Immediately following the file
  1415. size is where the data stream for the file begins.
  1416.  
  1417. Once the data transfer is initiated, the downloader should notify the server
  1418. that they are downloading a file by sending the 218 message.  Once the
  1419. transfer is complete, you send a 219 message to indicate you have finished
  1420. the download.  Note that this is cummalitive, so that if you are downloading
  1421. multiple files, you send one 218/219 pair for EACH concurrent download--this
  1422. is how the server knows how many transfers you have going on.  Likewise,
  1423. the uploader should send one 220 messge for each upload, and one 221 when
  1424. each upload has finished.
  1425.  
  1426. 5.2  Firwalled Downloading
  1427.  
  1428. As described above, when the file needs to be pushed from a client behind a
  1429. firewall, the downloader sends a 500 message to the server.  This causes a
  1430. 501 message to be sent to the uploader, which is similar to the 204 message
  1431. for a normal download.
  1432.  
  1433. Once the uploader receives the 501 message from the server, they should make
  1434. a TCP connection to the downloader's data port (given in the 501 message).
  1435. Upon connection, the downloader's client will sent one byte, the ASCII
  1436. character `1'.  The uploader should then send the string "SEND" in a single
  1437. packet, and then the information:
  1438.     <mynick> "<filename>" <size>
  1439. where <mynick> is the uploader's napster user name, <filename> is the file
  1440. being sent, and <size> is the size of the file in bytes.
  1441.  
  1442. Upon receipt, the downloading client will either send the byte offset at
  1443. whcih the transfer should start, or an error message such as
  1444. "INVALID REQUEST".  The byte offset should be sent as a single packet
  1445. in plain ASCII digits.  Just as with above in section 4.1, a 0 byte offset
  1446. indicates the transfer should begin at the start of the file.
  1447.  
  1448. Each client should notify the server that they are uploading or downloading
  1449. with the 218/219 (downloading) or 220/221 (uploading) command pairs (see
  1450. section 4.1 for more detailed information).
  1451.  
  1452. 5.3 Client to Client Browsing
  1453.  
  1454. Napster 2.0 BETA 8 adds a feature which allows direct client-to-client
  1455. browsing of file lists.  To request a browse, a client uses the
  1456.     640 <nick>
  1457. command.  The server then sends a
  1458.     640 <requester>
  1459. to the client which is getting browsed with the nick of the client that is
  1460. requesting the browse.  If the client accepts the browse request, it sends
  1461. back a
  1462.     641 <requestor>
  1463. to the server with the nick of the client requesting the browse.  The
  1464. server then sends a
  1465.     641 <nick> <ip> <port>
  1466. to the requesting client.  In the case of an error, the server will send a 642
  1467. command in response to the 640 command.
  1468.  
  1469. The browsing client then makes a TCP conection to the remote client's data
  1470. port.  After getting the "1" character, the browsing client sends a
  1471.     GETLIST
  1472. At which point the remote client sends its nick followed by a linefeed (\n)
  1473. by itself in a single packet (ie, one write() call)
  1474.     <nick> LF
  1475. followed by the list of files being shared (the format being the same as
  1476. the data of the "share" command).  Each line is terminated by a linefeed char.
  1477. At the end of the list, an additional linefeed char is sent and then the
  1478. client closes the connection.
  1479.  
  1480. In the case that the remote client is firewalled, the browse list will have to
  1481. be pushed to the requesting client.  The remote client makes a TCP connection
  1482. to the requesting client, then sends
  1483.     SENDLIST <nick>\n
  1484. followed by the list of files, as with the "GETLIST" command response.
  1485.  
  1486. 6.  Where to get more help?
  1487.  
  1488. Join the napdev mailing list by sending email to napdev-subscribe@onelist.com
  1489. or by visiting the community page http://www.onelist.com/community/napdev/.
  1490. This list is designed for open source napster developers to share information
  1491. about the specification or applications.
  1492.  
  1493. 7.  Acknowledgements
  1494.  
  1495. A big THANKS goes to the following people who contributed valuable information
  1496. to this specification:
  1497.  
  1498. Ben Byer <bbyer@rice.edu>
  1499. JT <jtraub@dragoncat.net>
  1500. Evan Martin <eeyem@u.washington.edu>
  1501. Colten Edwards (aka panasync@efnet) <edwards@bitchx.dimension6.com>
  1502. Thomas van der Heijden <thom@bart.nl>
  1503.